/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.ana.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author lucas.nunes
 */
@Entity
@Table(name = "QLTTB_USINA_LOCALIZACAO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "UsinaLocalizacao.findAll", query = "SELECT u FROM UsinaLocalizacao u"),
    @NamedQuery(name = "UsinaLocalizacao.findByUslId", query = "SELECT u FROM UsinaLocalizacao u WHERE u.uslId = :uslId"),
    @NamedQuery(name = "UsinaLocalizacao.findByUsinaRio", query = "SELECT u FROM UsinaLocalizacao u WHERE u.uslUsiId = :uslUsiId"),
    @NamedQuery(name = "UsinaLocalizacao.deleteUsinaLocalizacaoByUsina", query = "DELETE FROM UsinaLocalizacao u WHERE u.uslUsiId = :uslUsiId")})

@SequenceGenerator(name = "sequenceUsinaLocalizacao", sequenceName = "SQ_QLTTB_USINA_LOCALIZACAO", allocationSize = 1)
public class UsinaLocalizacao implements Serializable {

    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "USL_ID")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceUsinaLocalizacao")
    private BigDecimal uslId;
    @JoinColumn(name = "USL_USI_ID", referencedColumnName = "USI_ID")
    @ManyToOne
    private Usina uslUsiId;
    @JoinColumn(name = "USL_UFD_CD", referencedColumnName = "UFD_CD")
    @ManyToOne
    private UnidadeFederacao uslUfdCd;
    @JoinColumn(name = "USL_RIO_CD", referencedColumnName = "RIO_CD")
    @ManyToOne
    private Rio uslRioCd;
    @JoinColumn(name = "USL_MUN_CD", referencedColumnName = "MUN_CD")
    @ManyToOne
    private Municipio uslMunCd;

    public UsinaLocalizacao() {
    }

    public UsinaLocalizacao(BigDecimal uslId) {
        this.uslId = uslId;
    }

    public BigDecimal getUslId() {
        return uslId;
    }

    public void setUslId(BigDecimal uslId) {
        this.uslId = uslId;
    }

    public Usina getUslUsiId() {
        return uslUsiId;
    }

    public void setUslUsiId(Usina uslUsiId) {
        this.uslUsiId = uslUsiId;
    }

    public UnidadeFederacao getUslUfdCd() {
        return uslUfdCd;
    }

    public void setUslUfdCd(UnidadeFederacao uslUfdCd) {
        this.uslUfdCd = uslUfdCd;
    }

    public Rio getUslRioCd() {
        return uslRioCd;
    }

    public void setUslRioCd(Rio uslRioCd) {
        this.uslRioCd = uslRioCd;
    }

    public Municipio getUslMunCd() {
        return uslMunCd;
    }

    public void setUslMunCd(Municipio uslMunCd) {
        this.uslMunCd = uslMunCd;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (uslId != null ? uslId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UsinaLocalizacao)) {
            return false;
        }
        UsinaLocalizacao other = (UsinaLocalizacao) object;
        if ((this.uslId == null && other.uslId != null) || (this.uslId != null && !this.uslId.equals(other.uslId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "" + this.uslId.intValue() + " - " + uslRioCd.getRioNm()+"("+uslRioCd.getRioCd().toString()+")" + ", " + uslMunCd.getMunNm() + "/" +uslUfdCd.getUfdSg();
        //return "" + this.uslId.intValue();
    }
}
